cmake_minimum_required(VERSION 3.10)

project(use_custom_lib)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

include_directories(${PROJECT_SOURCE_DIR}/include)

set(SRC_FILES src/use_main.c)

# 在指定目录下查找指定库，并把库的绝对路径存放到变量里
find_library(LIBS demo HINTS ${PROJECT_SOURCE_DIR}/lib)

add_executable(uselib ${SRC_FILES})

# 把目标文件与库文件进行链接
target_link_libraries(uselib ${LIBS})